package org.zjz.basket.util;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * Desc: 请求工具类
 *
 * @author gezq
 * @since 0:34 - 2022/5/8
 */
public final class RequestUtils {
    public static String getHeaderValue(String key) {
        String res = "";
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        if (attributes instanceof ServletRequestAttributes) {
            HttpServletRequest request = ((ServletRequestAttributes) attributes).getRequest();
            res = request.getHeader(key);
        }
        return res;
    }
}
